<#include '/admin/header.html' >
<div class="main">
		<div  class="input shadowBoxWhite wf100 whiteBox">
		<input name="showcase_inputAction" id="floor_inputAction" type="hidden" value="${actionName!''}">
		<form method="post" name="theForm" id="theForm" enctype="multipart/form-data">
			<div class="text" style="padding: 20px 15px;">
				<input type="hidden" name="id" value="${showcase.id!''}" >
				<table class="form-table">
					<tbody>
						<th style="text-align: left;" align="left" colspan="2" class="groupname title">基本信息</th>
						<tr>
							<th>标题:</th>
							<td style="text-align: left;">
								<input class="easyui-validatebox input_text validatebox-text validatebox-invalid"
								type="text"	maxlength="20" isrequired="true" datatype="string"
								data-options="required:true" name="title" autocomplete="off" title="" value="${showcase.title!''}" >
							</td>
						</tr>

						<tr>
							<th>排序:</th>
							<td style="text-align: left;">
								<input class="easyui-validatebox input_text validatebox-text validatebox-invalid"
								type="text"	maxlength="5" isrequired="true" datatype="string" value="${showcase.sort!''}"
								data-options="required:true" name="sort" autocomplete="off" title="" onkeyup="this.value=this.value.replace(/[^\d]/g,'') ">
							橱窗显示的顺序
							</td>
						</tr>

						<tr>
							<th>显示:</th>
							<td style="text-align: left;">
								<input type="radio" name="is_display" value="0" <#if showcase.is_display?? && showcase.is_display==0>checked="checked"</#if>>显示
								<input type="radio" name="is_display" value="1" <#if showcase.is_display?? && showcase.is_display==1>checked="checked"</#if>>不显示
							</td>
						</tr>
						<tr>
							<th>橱窗标识:</th>
							<td style="text-align: left;">
								<input class="easyui-validatebox input_text validatebox-text validatebox-invalid"
								type="text"	maxlength="20" isrequired="true" datatype="string" value="${showcase.flag!''}"
								data-options="required:true" name="flag" autocomplete="off" title="" onkeyup="value=value.replace(/[\u4E00-\u9FA5]/g,'')" >
							首页橱窗默认为index_top,如果想增加其他标识请修改对应页面代码,否则页面不显示橱窗
							</td>
						</tr>

						<tr>
							<th style="text-align: left;" align="left" colspan="2" class="groupname title">橱窗内容</th>
							<td style="text-align: left;">
								<input type="hidden" id="content" name="content" value="${showcase.content!''}" >
								<!-- <a href="javascript:;" id="add_content_button" class="button blueButton">添加展示商品</a> -->
							</td>
						</tr>

					</tbody>
				</table>
			</div>
		</form>
		<div class="showcase_goods"></div>
		<div class="buttonWrap">
			<a href="javascript:;" id="showcaseinput" class="easyui-linkbutton">确定</a>
		</div>
	</div>
</div>
<script type="text/javascript" src="${ctx}/shop/admin/js/jquery.goodsSelector.js" > </script>
<script type="text/javascript">
	
	$(function() {
		//初始化商品选择器
		var container=$(".showcase_goods");
		var options={
				goodsid_name:'goods_ids',
				selected_data_url:'${ctx}/core/admin/showcase/get-selected-goods.do?id='+${showcase.id!''},
		};
		container.goodsSelector(options);

		//绑定确认按钮
		$("#showcaseinput").click(function(){
			$("#showcaseinput").unbind("click");
			var goods_ids = [];
			$("input[name='goods_ids']").each(function(i, o){
				goods_ids[i] = $(o).val();
			});
			$("#content").val(goods_ids); 
			var disabled=  $(this).hasClass("l-btn-disabled");
			if( !disabled ){
				var formflag = $("#theForm").form('validate');
				if (formflag) {
					$("#floorinput").linkbutton("disable");
					$.Loading.show("正在保存请稍候..");
					var options = {
						url : $("#floor_inputAction").val() ,
						type : "POST",
						dataType : "json",
						success : function(result) {							
							if (result.result == 1) {
								$.Loading.success(result.message);
								parent.SelectTable("橱窗管理");
								parent.refreshCurrentTab();
								parent.CloseTabByTitle("橱窗编辑");
							}else{
								$.Loading.error(result.message);
								$("#floorinput").linkbutton("enable");
							}
						},
						error : function(e) {
							$.Loading.error("出错了,请重试");
							$("#floorinput").linkbutton("enable");
						}
					};
					$('#theForm').ajaxSubmit(options);
				}else{
					$.Loading.error("请检查数据");
				}
			}
		});
			
	});
	
	
</script>

<#include '/admin/footer.html' >
